﻿<Window x:Class="TextReader.View.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:v="clr-namespace:TextReader.View"
        xmlns:vm="clr-namespace:TextReader.ViewModel"
        Title="Text Reader"
        vm:AttachedProperties.RegisterCommandBindings="{Binding CommandBindings}" 
        Icon="icon.ico"
        Height="600" Width="573">
    <Window.Resources>
        <Style x:Key="ToolBarButton" TargetType="Button">
            <Setter Property="Opacity" Value="0.5"/>
            <Style.Triggers>
                <Trigger Property="IsEnabled" Value="True">
                    <Setter Property="Opacity" Value="1" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="200*" />
        </Grid.RowDefinitions>
        <Menu>
            <MenuItem Header="_File">
                <MenuItem Header="_Exit" Command="{Binding CloseCommand}" />
            </MenuItem>
            <MenuItem Header="_Playback">
                <MenuItem Header="_Rate">
                    <StackPanel Orientation="Horizontal" Height="25">
                        <Slider Width="100" Value="{Binding Rate}" Minimum="-10" Maximum="10" SmallChange="1" />
                        <Label Content="{Binding Rate}"/>
                    </StackPanel>
                </MenuItem>
                <MenuItem Header="_Volume">
                    <StackPanel Orientation="Horizontal" Height="25">
                        <Slider Width="100" Value="{Binding Volume}" Minimum="0" Maximum="100" SmallChange="1" LargeChange="10" />
                        <Label Content="{Binding Volume}"/>
                    </StackPanel>
                </MenuItem>
                <MenuItem Header="_Voice">
                    <StackPanel Orientation="Horizontal" Height="25">
                        <ComboBox
                          ItemsSource="{Binding Voices}" SelectedValue="{Binding Voice}" 
                          Width="120">
                        </ComboBox>
                    </StackPanel>
                </MenuItem>
            </MenuItem>
        </Menu>

        <ToolBarTray Grid.Row="1">
            <ToolBar>
                <Button Command="ApplicationCommands.New" Style="{StaticResource ToolBarButton}">
                    <Image Source="toolbargraphics\new.ico" />
                </Button>
            </ToolBar>
            <ToolBar>
                <Button Command="MediaCommands.Play" Style="{StaticResource ToolBarButton}">
                    <Image Source="toolbargraphics\play.ico" />
                </Button>
                <Button Command="MediaCommands.Pause" Style="{StaticResource ToolBarButton}">
                    <Image Source="toolbargraphics\pause.ico"/>
                </Button>
                <Button Command="MediaCommands.Stop" Style="{StaticResource ToolBarButton}">
                    <Image Source="toolbargraphics\stop.ico"/>
                </Button>
            </ToolBar>
            <ToolBar>
                <Button Command="EditingCommands.MoveToDocumentStart" Style="{StaticResource ToolBarButton}">
                    <Image Source="toolbargraphics\home.ico"/>
                </Button>
                <Button Command="EditingCommands.MoveToDocumentEnd" Style="{StaticResource ToolBarButton}">
                    <Image Source="toolbargraphics\end.ico"/>
                </Button>
                <Button Command="{Binding RemoveEmptyCommand}" Style="{StaticResource ToolBarButton}">
                    <Image Source="toolbargraphics\rmvempt.ico"/>
                </Button>
                <Button Command="{Binding UniteLinesCommand}" Style="{StaticResource ToolBarButton}">
                    <Image Source="toolbargraphics\uniteln.ico"/>
                </Button>
            </ToolBar>
        </ToolBarTray>
        <TabControl Grid.Row="2" ItemsSource="{Binding Documents}" SelectedItem="{Binding Document}">
            <TabControl.ItemTemplate>
                <DataTemplate>
                    <DockPanel>
                        <Border BorderThickness="0,0,5,0">
                            <TextBlock Text="{Binding Path=Name}"/>
                        </Border>
                        <Button Command="{Binding Path=CloseCommand}" Height="15" Width="15" DockPanel.Dock="Right">
                            <Button.Template>
                                <ControlTemplate TargetType="ButtonBase">
                                        <ContentPresenter Content="{TemplateBinding ContentControl.Content}" />
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsMouseOver" Value="False">
                                            <Setter Property="Opacity" Value="0.5"></Setter>
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Button.Template>
                            <Image Source="cross.ico"/>
                        </Button>
                    </DockPanel>
                </DataTemplate>
            </TabControl.ItemTemplate>
            <TabControl.ContentTemplate>
                <DataTemplate>
                    <Grid>
                        <v:FlowDocumentView/>
                    </Grid>
                </DataTemplate>
            </TabControl.ContentTemplate>
        </TabControl>
    </Grid>
</Window>
